<?php
namespace Index\Controller;
use Think\Controller;
class IndexController extends CommonController {
    //主页展示
    public function index(){
    	//取置顶	
    	$sql="select t1.*,t2.face,t2.nickname,t3.name from question t1 inner join user t2 on t1.uid=t2.id inner join category t3 on t1.cid=t3.id where t1.top=1 limit 5";
    	$topData=M()->query($sql);
        $count      = M('question')->count();// 查询满足要求的总记录数
        $Page       = new \Think\Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show       = $Page->show();// 分页显示输出
        //取主页展现的
        $sql="select t1.*,t2.face,t2.nickname,t3.name from question t1 inner join user t2 on t1.uid=t2.id inner join category t3 on t1.cid=t3.id order by t1.create_time desc limit ".$Page->firstRow.','.$Page->listRows;

        $arrData=M()->query($sql);

    	//主页热门回答
    	$hotytime=D('user')->hotytime();
    	// var_dump($hotytime);
    	//主页热门阅览
    	$hotview=D('question')->hotview();
    	//主页热门品论
    	$hotanswer=D('question')->hotanswer();
    	//分配
        $this->assign('show',$show);
        $this->assign('arrData',$arrData);
    	$this->assign('hotanswer',$hotanswer);
    	$this->assign('hotview',$hotview);
    	$this->assign('hotytime',$hotytime);
        $this->assign('topData',$topData);
        //首页标题说明
        $this->assign('title',"最后一刻子弹留给我");
       $this->display();

    }

}
?>